import { defineStore } from 'pinia'

// export const useCounterStore = defineStore('counter', {
//     state: () => ({
//         count: 99,
//         msg:'wsapp'
//     }),
//     getters: {
//         doubleCount: (state) => state.count * 2,
//       },
//     actions: {
//         increment() {
//             this.count++
//         },
//         decrement() {
//             this.count--
//             }
//     }
// })
// http://geek.itheima.net/v1_0/channels
export const useCounterStore = defineStore('counter', () => {
    const count = ref(99999)
    const msg = ref('wsapp')

    const doubleCount = computed(() => count.value * 2)
    function increment() {
        count.value++
    }
    function decrement() {
        count.value--
    }
    return { count, doubleCount,msg, increment,decrement }
},{
    persist: {
        key:'heiam',
        storage:window.sessionStorage,
        paths: ['count'],
    },
})